<template>
  <div class='content'>
    <div class="top">
      <el-input v-model="serchVal" placeholder="请输入内容"></el-input>
      <el-select v-model="inventoryType" placeholder="请选择库存类型">
        <el-option label="生活用品" value="live"></el-option>
        <el-option label="美味食物" value="food"></el-option>
        <el-option label="数码3c " value="3c"></el-option>
      </el-select>
      <el-button type="primary" size="medium">搜索</el-button>
    </div>

    <div class="tables">
      <el-table :data="tableData" stripe style="width: 100%">
        <!-- 设置表头数据源，并循环渲染出来，property对应列内容的字段名 -->
        <el-table-column v-for="info in rightHeader" :key="info.key" :property="info.key" :label="info.label"
          align="center">
          <template slot-scope="scope">
             <!-- 渲染对应表格里面的内容 -->
             <span v-if="scope.row.isDisabled">{{scope.row[scope.column.property]}}</span>
             <el-input v-else v-model="scope.row[scope.column.property]"></el-input>
          </template>
        </el-table-column>
        <el-table-column prop="set" label="操作" width="200" fixed="right" align="center">
          <template slot-scope="scope">
            <el-button :type="!scope.row.isDisabled?'success':'primary'" size="small">{{!scope.row.isDisabled?'确认':'修改'}}</el-button>
            <el-button type="danger" size="small">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="pages">
      <el-pagination background layout="prev, pager, next" :page-size="10" :total="100"
        @current-change="handleCurrentChange">
      </el-pagination>
    </div>
  </div>
</template>

<script>
  export default {
    //import引入的组件需要注入到对象中才能使用
    components: {},
    data() {
      //这里存放数据
      return {
        serchVal: null,
        inventoryType: null,
        rightHeader: [{
            label: '产品名称',
            key: 'name'
          },
          {
            label: '编号',
            key: 'id'
          },
          {
            label: '品牌',
            key: 'brand'
          },
          {
            label: '型号',
            key: 'model'
          },
          {
            label: '类型',
            key: 'type'
          },
          {
            label: '单价',
            key: 'price'
          },
          {
            label: '数量',
            key: 'num'
          },
          {
            label: '备注',
            key: 'notic'
          },

        ],
        tableData: [{
          name: '产品1',
          id: 'abc123',
          brand: '苹果',
          model: 'iphonex',
          price: 10,
          num: 1000,
          type: '磨砂膜',
          isDisabled:false,
        }, {
          name: '产品2',
          id: 'abc123',
          brand: '苹果',
          model: 'iphonex',
          price: 10,
          num: 1000,
          type: '磨砂膜',
          isDisabled:true,
        }, {
          id: 'abc123',
          name: '产品3',
          brand: '苹果',
          model: 'iphonex',
          price: 10,
          num: 1000,
          type: '磨砂膜',
          isDisabled:true,
        }, {
          id: 'abc123',
          name: '产品4',
          brand: '苹果',
          model: 'iphonex',
          price: 10,
          num: 1000,
          type: '磨砂膜',
          isDisabled:true,
        }]
      };
    },
    //监听属性 类似于data概念
    computed: {},
    //监控data中的数据变化
    watch: {},
    //方法集合
    methods: {
      //确认或修改
      btnState(e){console.log(e)},
       //翻页
      handleCurrentChange(e) {
        console.log(e)
      },
    },
    //生命周期 - 创建完成（可以访问当前this实例）
    created() {

    },
    //生命周期 - 挂载完成（可以访问DOM元素）
    mounted() {

    },
    beforeCreate() {}, //生命周期 - 创建之前
    beforeMount() {}, //生命周期 - 挂载之前
    beforeUpdate() {}, //生命周期 - 更新之前
    updated() {}, //生命周期 - 更新之后
    beforeDestroy() {}, //生命周期 - 销毁之前
    destroyed() {}, //生命周期 - 销毁完成
    activated() {}, //如果页面有keep-alive缓存功能，这个函数会触发
  }

</script>
<style lang='scss' scoped>
  @import '~@/styles/chow.scss';

</style>
